/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.stat;

import android.text.TextUtils;
import java.util.Vector;
import org.json.JSONObject;

public class n {
    private static String g = "SessionBean";
    public String a = "";
    public long b = 0L;
    public long c = 0L;
    public Vector d = new Vector();
    public long e = 0L;
    public long f = 0L;

    public n() {}

    public n(String paramString, long paramLong) {
        this.a = paramString;
        this.b = paramLong;
    }

    public void a() {
        if (this.d != null) {
            this.d.clear();
            this.d = null;
        }
        this.a = "";
        this.b = 0L;
        this.c = 0L;
        this.e = 0L;
        this.f = 0L;
    }

    public void a(String paramString) {
        if (TextUtils.isEmpty(paramString))
            return;
        int i = 0;
        g localg = null;
        if (this.d == null)
            this.d = new Vector();
        for (int j = 0; j < this.d.size(); ++j) {
            localg = (g) this.d.get(j);
            if (!(paramString.equals(localg.a)))
                continue;
            localg.b = ai.o();
            i = 1;
            break;
        }
        if (i != 0)
            return;
        this.d.add(new g(paramString, ai.o()));
    }

    public void b(String paramString) {
        if (TextUtils.isEmpty(paramString))
            return;
        g localg = null;
        if (this.d == null)
            this.d = new Vector();
        for (int i = 0; i < this.d.size(); ++i) {
            localg = (g) this.d.get(i);
            if (!(paramString.equals(localg.a)))
                continue;
            localg.c = ai.o();
            if (0L == localg.b)
                return;
            localg.d += localg.c - localg.b;
            localg.b = 0L;
            return;
        }
    }

    public JSONObject b() {
        JSONObject localJSONObject1 = new JSONObject();
        try {
            localJSONObject1.put("session", this.a);
            localJSONObject1.put("createTime", this.b);
            localJSONObject1.put("terminateTime", this.c);
            if (this.e > 0L)
                localJSONObject1.put("uptr", this.e);
            if (this.f > 0L)
                localJSONObject1.put("dntr", this.f);
            if (ac.f) {
                JSONObject localJSONObject2 = null;
                g localg = null;
                if ((this.d != null) && (this.d.size() > 0)) {
                    localJSONObject2 = new JSONObject();
                    for (int i = 0; i < this.d.size(); ++i) {
                        localg = (g) this.d.get(i);
                        localJSONObject2.put(localg.a, localg.d);
                    }
                    localJSONObject1.put("activity", localJSONObject2);
                }
            }
        } catch (Exception localException) {
            x.a(g, localException);
        } catch (Error localError) {
            x.a(g, localError);
        }
        return localJSONObject1;
    }
}